package com.app.interceptor;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 后台拦截器
 */
public class BackendInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //判断session中是否有登录的管理员
        if (request.getSession().getAttribute("login") == null) {
            response.sendRedirect( request.getContextPath() + "/warn.jsp");
            return false;
        }
        return true;

    }

}
